package model

import (
	"errors"
)

type Blog struct {
	BaseModel
	Title       string `gorm:"column:title" json:"title" form:"title"`
	Content     string `gorm:"column:content" json:"content" form:"content"`
	Md          string `gorm:"column:md" json:"md" form:"md"`
	Description string `gorm:"column:description" json:"description" form:"description"`
	Catid       int    `gorm:"column:catid" json:"catid" form:"catid"`
	Status      int    `gorm:"column:status" json:"status" form:"status"`
	Likes       int    `gorm:"column:likes" json:"likes" form:"likes"`
	Views       int    `gorm:"column:views" json:"views" form:"views"`
	Avatar      string `gorm:"column:avatar;type:varchar(200)" json:"avatar"`
	Author      string `gorm:"column:author" json:"author" form:"author"`
	Total       string `gorm:"-"`
	ColTitle    string `gorm:"column:colTitle" json:"colTitle"`
}

func (b *Blog) IsValid() (err error) {
	if b.Title == "" {
		err = errors.New("标题不能为空")
	}
	return
}
